﻿using System;
using System.Threading;
using System.Windows.Forms;
using Common;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;

namespace CatalogSystem
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

            var client = TopicClient.Create("catalog");
            var payload = new ItemCreated
                              {
                                  Name = textBox1.Text,
                                  Description = textBox2.Text,
                                  Price = Convert.ToDouble(textBox3.Text)
                              };
            var message = new BrokeredMessage(payload);
            client.Send(message);
        }
    }
}
